package com.shph.validation.adapter.impl;

import com.shph.validation.adapter.RuleParse;
import com.shph.validation.rule.IRule;

public class StringRuleParse implements RuleParse<String> {
    @Override
    public IRule parse(String ruleType) {
        Object o = null;
        try {
            o = Class.forName(ruleType).newInstance();
        } catch (InstantiationException | ClassNotFoundException | IllegalAccessException e) {
            e.printStackTrace();
        }

        if (o instanceof IRule) {
            return (IRule) o;
        }

        return null;
    }
}
